package com.ruoyi.btlfbreed.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.btlfbreed.domain.TbChickenDeathRecords;
import com.ruoyi.btlfbreed.service.ITbChickenDeathRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 肉鸡死亡登记Controller
 * 
 * @author codeman
 * @date 2024-05-07
 */
@RestController
@RequestMapping("/btlfbreed/chickenDeathRecords")
public class TbChickenDeathRecordsController extends BaseController
{
    @Autowired
    private ITbChickenDeathRecordsService tbChickenDeathRecordsService;

    /**
     * 查询肉鸡死亡登记列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbChickenDeathRecords tbChickenDeathRecords)
    {
        startPage();
        List<TbChickenDeathRecords> list = tbChickenDeathRecordsService.selectTbChickenDeathRecordsList(tbChickenDeathRecords);
        return getDataTable(list);
    }

    /**
     * 导出肉鸡死亡登记列表
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:export')")
    @Log(title = "肉鸡死亡登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbChickenDeathRecords tbChickenDeathRecords)
    {
        List<TbChickenDeathRecords> list = tbChickenDeathRecordsService.selectTbChickenDeathRecordsList(tbChickenDeathRecords);
        ExcelUtil<TbChickenDeathRecords> util = new ExcelUtil<TbChickenDeathRecords>(TbChickenDeathRecords.class);
        util.exportExcel(response, list, "肉鸡死亡登记数据");
    }

    /**
     * 获取肉鸡死亡登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbChickenDeathRecordsService.selectTbChickenDeathRecordsById(id));
    }

    /**
     * 新增肉鸡死亡登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:add')")
    @Log(title = "肉鸡死亡登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbChickenDeathRecords tbChickenDeathRecords)
    {
        return toAjax(tbChickenDeathRecordsService.insertTbChickenDeathRecords(tbChickenDeathRecords));
    }

    /**
     * 修改肉鸡死亡登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:edit')")
    @Log(title = "肉鸡死亡登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbChickenDeathRecords tbChickenDeathRecords)
    {
        return toAjax(tbChickenDeathRecordsService.updateTbChickenDeathRecords(tbChickenDeathRecords));
    }

    /**
     * 删除肉鸡死亡登记
     */
    @PreAuthorize("@ss.hasPermi('btlfbreed:chickenDeathRecords:remove')")
    @Log(title = "肉鸡死亡登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbChickenDeathRecordsService.deleteTbChickenDeathRecordsByIds(ids));
    }
}
